<?php 
include "includes/session.php";
include "includes/comunes.php";

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Sistema de Gestion de Vehiculos</title>

<link href="estilos.css" rel="stylesheet" type="text/css" />

<!--libreria jquery central-->
<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->

<!--Librerias para el combo-->
<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<!--fin libreria-->

<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--estilo para el scroll-->
<style>
  .ui-autocomplete {
    max-height: 300px;
    overflow-y: auto;
    /* prevent horizontal scrollbar */
    overflow-x: hidden;
  }
  /* IE 6 doesn't support max-height
   * we use height instead, but this forces the menu to always be this tall
   */
  * html .ui-autocomplete {
    height: 300px;
  }
  </style>
<!--
  fin estilo scroll-->
<style type="text/css">
 
#tabla{	width: 100%; }
.fila-base{ display: none; } /* fila base oculta */
.eliminar{ cursor: pointer; color: #000; }
#tablagastos{	width: 100%; }
.fila-base-gastos{ display: none; } /* fila base oculta */
.eliminargasto{ cursor: pointer; color: #000; }
 
</style>



<script language="JavaScript" type="text/javascript">
$(function()
{




$("#enviar").submit(function () {

     var precioTotal= 2345
                  if (confirm('Esta seguro que confirma los datos cargados?')){ 
					   return true;
					}else
					   return false;
});

$( "#clidni" ).autocomplete({
			source: "autoPersona.php"
		});
        

$("#imgbus").click(function(evento){
      evento.preventDefault();
      $("#comprador").load("datosCliente.php", {dni: $("#clidni").val()});
   });
   
   
 $("#vehiculo").change(function(evento){
      evento.preventDefault();
      $("#precioVenta").load("precioVenta.php", {veh: $("#vehiculo").val()});
   });  
   
   
			 
   
   
 $("#contipo").change(function(evento){
      evento.preventDefault();
      $("#formaPago").load("formaPago.php", {tipo: $("#contipo").val()});
	   
   });  
 

     $('#clipro').chainSelect('#cliloc','comboprolocalidad.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});

	
		
             
             
        
			 
			 
	$("#agregar").on('click', function(){
	$("#tabla tbody tr:eq(0)").clone().removeClass('fila-base').appendTo("#tabla tbody");
	});
 
	// Evento que selecciona la fila y la elimina 
	$(document).on("click",".eliminar",function(){
		var parent = $(this).parents().get(0);
		$(parent).remove();
	});
			 
			 
	$("#agregargasto").on('click', function(){
		$("#tablagastos tbody tr:eq(0)").clone().removeClass('fila-base-gastos').appendTo("#tablagastos tbody");
	});
 
	// Evento que selecciona la fila y la elimina 
	$(document).on("click",".eliminargasto",function(){
		var parent = $(this).parents().get(0);
		$(parent).remove();
	});
	
	
	
	//calculo el total
			 $(document).on("change","#montopago",function(){
                        importe_total = $("#precio").val ;
						$("#montogasto").each(
							function(index, value) {
								importe_total = importe_total + eval($(this).val());
								}
						);
						$("#total").val(importe_total);
             });
             
	

});
</script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
</head>

<body>

<div class="container">
<?php include "includes/head.php"?>
   <div class="content">
       <div class="tituloprincipal">
          <?php include 'includes/submenu.php';?>  
           <img src="img/nuevo.png" width="25" height="25" border="0"/> Alta de Personas</div>
       <form id="enviar"  method="POST" action="grabarCliente.php">
       <div class="contenedorpedido">
		  
	   
      
       
       
           <div id="comprador">
           <fieldset>
              <legend><b>Datos del Cliente</b></legend> 
               <table  width="100%">
                 <tr>
                      <td class="textotablamenuform">Tipo</td>
                      <td class="textotablamenuform">
                          <select name="clitipo" id="clitipo" class="campo_form" required>
                              <option value='1'>Persona Fisica</option>
                              <option value='2'>Persona Juridica</option>
                         </select>
                      </td>
                      <td class="textotablamenuform">Dni/Cuit</td>
                      <td class="textotablamenuform">
                           <input type="number" class="campo_form" autocomplete="on" placeholder="Ej. 28992993" id="clidni" name="clidni" required style="width:80%;">
                           <img src="img/actualizar.jpg" width="20" id="imgbus" style="margin-top:15px;"/>
                      </td>
                      
                 </tr>
                   <tr>
                      <td class="textotablamenuform">Nombre y Apellido</td>
                      <td class="textotablamenuform" colspan="5">
                           <input type="text" class="campo_form"  id="cliape" name="cliape" required>
                               
                      </td> 
                   </tr>
                   
                   <tr>
                      <td class="textotablamenuform">Telefono Fijo</td>
                      <td class="textotablamenuform">
                          <input type="number" class="campo_form" placeholder="Ej. 03624 764244" id="clitelf" name="clitelf">
                    
                      </td>
                      <td class="textotablamenuform">Telefono Celular</td>
                      <td class="textotablamenuform">
                          <input type="number" class="campo_form" placeholder="Ej. 0362 154764244" id="clitelc" name="clitelc">
                    
                      </td>
                      
                 </tr>
                   <tr>
                      
                      <td class="textotablamenuform">Direccion</td>
                      <td class="textotablamenuform" colspan="2">
                           <input type="text" class="campo_form"  id="cliape" name="clidir" required>
                    
                      </td>
                       <td class="textotablamenuform">
                         <select name="clipro" id="clipro" class="campo_form" required>
                             <option selected value="0">Seleccionar...</option>
                             <?php
                             $cat=obtener_provincias();

                             while($regPed=mysql_fetch_array($cat)){
                                 echo "<option value='".utf8_encode($regPed['id_provincia'])."'>".utf8_encode($regPed['nombre'])."</option>";
                             }

                             ?>

                         </select>


                     </td>
                       <td class="textotablamenuform" colspan="3">
                         <select name="cliloc" id="cliloc" class="campo_form" required style="display:none">
                            

                         </select>


                     </td>
                 </tr>
                    <tr>
				 <td class="textotablamenuform">
				 Observacion
				 </td>
				 <td colspan="4">
				 <textarea name="cliObse" cols="65" class="campo_form"></textarea>
				 </td>
				 </tr>
                   
                   
               </table>    
           </fieldset>  
           </div>
      
       
           
           <fieldset style="text-align: right;">  
            <table style="text-align: right;">
             <tr>
                    <td class="textotablamenuform" style="text-align: right;" colspan="5">
                         <input type="reset" name="reset" value="Limpiar"  class="boton_form"/>
                         <input name="submit" id="submit" type="submit" value="Grabar Cliente" class="boton_form"/>
                     </td>
                 </tr>
                   </table>       
           </fieldset>  
           
           
           
       </div>
   </form>
       <div class="clear"></div>
   <br>
   </div>
  <?php include "includes/pie.php"?>
  
</div>
</body>
</html>
